/*
 * @Author: zhangguowei 974599791@qq.com
 * @Date: 2022-08-23 14:06:56
 * @LastEditors: zhangguowei 974599791@qq.com
 * @LastEditTime: 2022-10-11 17:33:18
 * @Description:
 */
import { createRouter, createWebHashHistory } from "vue-router";

const routes = [
  {
    path: "/HelloWorld",
    name: "HelloWorld",
    type: "systemManage",
    label: "helloworld",
    component: () => import("@/page/HelloWorld.vue"),
    // children: [
    //   {
    //     path: "/work",
    //     name: "Work",
    //     component: () =>
    //       import(/* webpackChunkName: "first" */ "@/views/WorkBench"),
    //     meta: { title: "工作台", icon: "icon-gongzuotai" },
    //   },
    // ],
  },
  {
    path: "/tableDemo",
    name: "表格示例",
    type: "userManage",
    label: "tableDemo",
    component: () => import("@/page/tableDemo.vue"),
  },
];

const adminRouter = [
  {
    path: "/",
    component: () => import("@/layout/index.vue"),
    children: routes,
  },
];
const menuCategories = {
  systemManage: {
    label: "系统管理",
    children: [],
    icon: () => {
      return (
        <el-icon>
          <setting />
        </el-icon>
      );
    },
  },
  userManage: {
    label: "用户管理",
    children: [],
    icon: () => {
      return (
        <el-icon>
          <user />
        </el-icon>
      );
    },
  },
};
// 处理菜单数据格式
routes.forEach((item: any) => {
  if (item.type) {
    item.typeName = menuCategories[item.type].label;
    menuCategories[item.type].children.push(item);
  }
});
// const finalRouter=
const router = createRouter({
  history: createWebHashHistory(),
  routes: adminRouter,
});

export default router;
export { menuCategories };
